﻿using BBICMS.Infrastructure.UI;
using BBICMS.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BBICMS.WebUI.Areas.bbi_Admin.Models
{
    public class PostListViewModel
    {
        public IEnumerable<Post> Posts { get; set; }
        public PagingInfo PagingInfo { get; set; }


        public string PostsJSON
        {
            get
            {
                JsonSerializerSettings settings =
                    new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    };

                settings.ContractResolver =
                    new CamelCasePropertyNamesContractResolver();


                var posts = JsonConvert.SerializeObject(this.Posts, settings);
                return posts;
            }
        }
    }
}